{include file="public/header" /}
<style>
    .layui-input-block{width: 50%}
</style>
<body>
<div class="x-body">
    <form action="{:url('agent_save')}" id="form"  method="post" class="form layui-form"  lay-filter='form'>
        <input type="hidden" name="id" value="{$info.id}"/>
        <input type="hidden" name="is_shop" value="{$info.is_shop}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">店铺类别 </label>

            <div class="layui-input-inline">
                <select name="shop_id" id="shop_id"  lay-filter="agent">
                    {foreach name="shop" item="vo"}
                    <option value="{$vo.id}"  {if isset($info) && $info.shop_id== $vo.id}selected{/if}>{$vo.title}</option>
                    {/foreach}
                </select>
            </div>

        </div>
        <div class="layui-form-item" style="text-align: center;">
            {if !$info.is_shop}
            <button class="layui-btn" lay-filter="save" lay-submit formObj="#form">设为店铺</button>
            {else}
            <button class="layui-btn" lay-filter="save" lay-submit formObj="#form">取消店铺</button>
            {/if}
        </div>
    </form>
</div>
</body>
{include file="public/footer" /}
<script src="/static/admin/builder/js/sunSelect.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form
        form.on('select(agent)', function (data) {
            console.log(data.value)
            if (data.value) {
                switch (data.value) {
                    case "1":
                        $(".province").show();
                        $(".city").hide();
                        $(".district").hide();
                        break;
                    case "2":
                        $(".city").show();
                        $(".province").show();
                        $(".district").hide();
                        break;
                    case "3":
                        $(".district").show();
                        $(".province").show();
                        $(".city").show();
                        break;
                    default:
                        $(".district").hide();
                        $(".province").hide();
                        $(".city").hide();
                }
            }
        });
    });
</script>
</html>